<div class="content-wrapper">
	<section class="content-header">
		<h1>功能组列表</h1>
		<ol class="breadcrumb">
			<li><a href="/admin"><i class="fa fa-dashboard"></i> 首页</a></li>
			<li class="active">权限管理</li>
			<li class="active">功能组列表</li>
		</ol>
	</section>
	<section class="content">
		<div class="box">
			<div class="box-header with-border">
				<form class="form-inline">
					<input type="hidden" name="id" id="id" value="{$groupInfo.id}" />
					<div class="form-group">
						<label for="name">功能组名 </label> 
						<input type="text" class="form-control" id="name" name="name" placeholder="功能组名" value="{$groupInfo.name}">
					</div>					
					<button type="button" class="btn btn-info" id="save-btn">{$groupInfo?'修改':'添加'}</button>&nbsp;
					<button type="button" class="btn btn-danger" onclick="window.location.href='/admin/auth/functionGroupList'">取消</button>
				</form>
			</div>
			<div class="box-body">
				<table class="table table-bordered">
					<tbody>
						<tr>
							<th style="width: 40px">ID</th>
							<th>功能组名</th>
							<th style="width: 215px">操作</th>
						</tr>
						<foreach name="groupList" item="group">
                        	<tr>
                        		<td>{$group.id}</td>
                        		<td>{$group.name}</td>
                        		<td>                        			
                        			<button class="btn btn-danger btn-xs" type="button" onclick="window.location.href='/admin/auth/functionGroupList?id={$group.id}'">修改</button>&nbsp;                        			
                        		</td>
                        	</tr>
                        </foreach>
					</tbody>
				</table>
			</div>			
		</div>
	</section>
</div>
<script type="text/javascript">
$(function(){
	$("#save-btn").click(function(){
		var id = $("#id").val();
		var name = $.trim($("#name").val());
		
		if(name == '') {
			ArtDialogHlp.showInfo('提示', '请填写功能组名');
            return false;
        }
		
		$.post('/admin/auth/saveFunctionGroup', {id:id, name:name}, function(data){
			if(data.Code == 999) {
				ArtDialogHlp.showInfo('提示', '操作成功', function(){
					window.location.href = '/admin/auth/functionGroupList';
				});
			} else {
				ArtDialogHlp.showInfo('提示', data.Msg);
			}
		}, 'json');
	});
});
</script>